package com.interaction.qualitytimeaiagent.demo.rag;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.rag.Query;
import org.springframework.ai.rag.preretrieval.query.expansion.MultiQueryExpander;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class MultiQueryExpender {

    @Resource
    private ChatClient.Builder chatClientBuilder;

    public MultiQueryExpender(ChatModel dashScopeChatModel){
        this.chatClientBuilder=ChatClient.builder(dashScopeChatModel);
    }
    public List<Query> expand(String query){
        MultiQueryExpander queryExpander = MultiQueryExpander.builder()
                .chatClientBuilder(chatClientBuilder)
                .numberOfQueries(3)
                .build();
        List<Query> queries = queryExpander.expand(new Query("什么是亲子互动"));
        return queries;
    }

}
